package com.xinhua.erp.controller;

import com.xinhua.erp.pojo.Result;
import com.xinhua.erp.pojo.Stockhouse;
import com.xinhua.erp.service.StockhouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController

@RequestMapping("stockhouse")

public class StockhouseController {

    @Autowired
    private StockhouseService stockhouseService;


    @GetMapping("{id}")
    public Result findById(@PathVariable long id) {
        return stockhouseService.findById(id);
    }

    @GetMapping("{page}/{size}")
    public Result findAll(@PathVariable int page, @PathVariable int size) {
        return stockhouseService.findAll(page, size);
    }

    @GetMapping
    public Result findAll() {
        return stockhouseService.findAll();
    }


    @DeleteMapping("{id}")
    public Result deleteById(@PathVariable long id) {
        return stockhouseService.deleteById(id);
    }

    @PostMapping
    public Result save(@RequestBody Stockhouse stockhouse) {
        return stockhouseService.save(stockhouse);
    }

    @PutMapping
    public Result update(@RequestBody Stockhouse stockhouse) {
        return stockhouseService.update(stockhouse);
    }
}
